﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Zor_Modes;
using Zor_IDAL;

namespace Zor_DAL
{
    public class Flow_DAL
    {
        /// <summary>
        /// 获取所有法规制度列表
        /// </summary>
        /// <returns></returns>
        public static List<FlowInfo> GetFlowList()
        {
            var sql = "select * from FlowInfo";
            List<FlowInfo> lsfw = DapperQuery<FlowInfo>.DoQueryList(sql, null);
            return lsfw;
        }


        /// <summary>
        /// 获取法规制度
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public static FlowInfo GetFlowById(int id)
        {
            var sql = "select * from FlowInfo where Flow_Id = @Flow_Id";
            FlowInfo flwo = DapperQuery<FlowInfo>.DoQueryT(sql, new { Flow_Id =id});
            return flwo;
        }

        /// <summary>
        /// 增加制度
        /// </summary>
        /// <param name="flow"></param>
        /// <returns></returns>
        public static BaseAnswer InsertFlow(FlowInfo flow)
        {
            BaseAnswer bar = new BaseAnswer();
            var sql = "insert into FlowInfo values(@Flow_Title,@Flow_Info,@Flow_CreateDate,@Flow_CreateUser)";
            bar = DapperInsert<FlowInfo>.DoInsert(sql, flow);
            return bar;
        }


        /// <summary>
        /// 编辑制度
        /// </summary>
        /// <param name="flow"></param>
        /// <returns></returns>
        public static BaseAnswer UpdateFlow(FlowInfo flow)
        {
            var sql = "update  FlowInfo set Flow_Info=@Flow_Info,Flow_Title=@Flow_Title,Flow_CreateDate=@Flow_CreateDate,Flow_CreateUser=@Flow_CreateUser where Flow_Id=@Flow_Id";
            BaseAnswer bar = DapperEdit<FlowInfo>.DoEdit(sql, flow);
            return bar;
        }

        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="ids"></param>
        /// <returns></returns>
        public static BaseAnswer DeleteFlow(int[] ids)
        {
            var sql = "delete from FlowInfo where Flow_Id in @Flow_Id";
            BaseAnswer bar = DapperDelete<FlowInfo>.DoDelete(sql, new { Flow_Id = ids });
            return bar;
        }

    }
}
